package test3;

/**
 * @Author Jun jie Yi
 * 2022/4/29 18:23
 */
public class Demo7 {
    public static void main(String[] args) {
        int[] arr = {1, 1};
        System.out.println(maxArea(arr));
    }

    public static int maxArea(int[] height) {
        int l = 0, r = height.length - 1, max = 0;
        //数字高的优先考虑留下
        int h, w, vol;
        while (l < r) {
            w = r - l;
            if (height[l] > height[r]) {
                h = height[r--];
            } else {
                h = height[l++];
            }
            vol = h * w;
            if (max < vol) {
                max = vol;
            }
        }
        return max;
    }
}
